const app = getApp()
const clientApi = app.ClientApi
const clientGet = app.clientGet
import store from '../../utils/store'
Component({
    properties: {

    },
    data: {
        orderDetail: {},
        show: false
    },
    methods: {
        async getOrder() {
            const factoryId = store.getItem("factoryId")
            const laneId = store.getItem('laneId')
            const orderData = await clientGet(`${clientApi.getOrderByLaneId}/factoryId/${factoryId}/laneId/${laneId}`)
            return orderData
        },
        onClose() {
            this.setData({
                show: false
            })
        }
    },
    lifetimes: {
        async attached() {
            const orderDetail = await this.getOrder()
            console.log("orderDetail", orderDetail)
            if (orderDetail) {
                this.setData({
                    show: true
                })
            }
            this.setData({orderDetail})
            this.triggerEvent('getOrderData', orderDetail)
        }
    }
});
